import React, { useState } from 'react'
import store from '../redux'
console.log(store)
export default function Home() {
    let [num,setNum] = useState(store.getState().num);
    // store.getState().属性名获取对应状态
    // 订阅状态 当状态发生改变时立即触发
    store.subscribe(()=>{
    //  console.log(store.getState().num)
     setNum(store.getState().num)
    })
  return (
    <div>
          <div>Home---{num}</div>
          <button onClick={()=>{
            // 触发更新store
            store.dispatch({
                type:"ADD"
            })
          }}>add</button>
    </div>
  )
}
